package com.yf.common;
 
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
 
@RestControllerAdvice
public class GlobalExceptionHandler {
 
    @ExceptionHandler
    public Resp handleError(BindException e) {
        BindingResult bindingResult = e.getBindingResult();
 
        return Resp.error(bindingResult.getFieldError().getDefaultMessage());
    }
}